//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//

//
#ifndef Green_InstructionGPGPU_H
#define Green_InstructionGPGPU_H

#include "Instruction.h"

namespace Green {

  /*!
    \class RetInstruction
    \brief class for RET instructions.
  */
  class RetInstruction : public Instruction {
  public:
    Object* Clone() const override { return new RetInstruction(*this); } //!< Return a cloned RetInstruction object of the same type and same contents of the object.
    const char* Type() const override { return "RetInstruction"; } //!< Return the type of the RetInstruction object in C string.

    RetInstruction() : Instruction() { } //!< Constructor
    ~RetInstruction() { } //!< Destructor.

    void Setup(const GenInstructionRequest& instrReq, Generator& gen) override; //!< Setup conditions, constrainting mechanisms before generation instruction.
    bool GetPrePostAmbleRequests(Generator& gen) const override; //!< Return preamble requests if there is any.
  protected:
    RetInstruction(const RetInstruction& rOther) : Instruction(rOther) { } //!< Copy constructor.
    InstructionConstraint* InstantiateInstructionConstraint() const override; //!< Return an instance of appropriate InstructionConstaint object.
  };

  /*!
    \class VectorAMOInstructionGPGPU
    \brief Class for GPGPU vector AMO instructions.
  */
  class VectorAMOInstructionGPGPU : public LoadStoreInstruction {
  public:
    DEFAULT_CONSTRUCTOR_DEFAULT(VectorAMOInstructionGPGPU);
    SUBCLASS_DESTRUCTOR_DEFAULT(VectorAMOInstructionGPGPU);
    ASSIGNMENT_OPERATOR_ABSENT(VectorAMOInstructionGPGPU);

    Object* Clone() const override { return new VectorAMOInstructionGPGPU(*this); } //!< Return a cloned VectorAMOInstructionGPGPU object of the same type and same contents of the object.
    const char* Type() const override { return "VectorAMOInstructionGPGPU"; } //!< Return the type of the VectorAMOInstructionGPGPU object in C string.
    bool Validate(const Generator& gen, std::string& error) const override; //!< Validates generation control for GPGPU VAMO instructions.
  protected:
    COPY_CONSTRUCTOR_DEFAULT(VectorAMOInstructionGPGPU);
  };

  /*!
    \class VsetvlInstruction
    \brief Class for VSETVL and VSETVLI instructions.
  */
  class VsetvlInstruction : public Instruction {
  public:
    DEFAULT_CONSTRUCTOR_DEFAULT(VsetvlInstruction);
    SUBCLASS_DESTRUCTOR_DEFAULT(VsetvlInstruction);
    ASSIGNMENT_OPERATOR_ABSENT(VsetvlInstruction);

    Object* Clone() const override { return new VsetvlInstruction(*this); } //!< Return a cloned Object of the same type and same contents as the Object being cloned.
    const char* Type() const override { return "VsetvlInstruction"; } //!< Return a string describing the actual type of the Object.
    bool GetPrePostAmbleRequests(Generator& gen) const override; //!< Return preamble requests if there is any.
  protected:
    COPY_CONSTRUCTOR_DEFAULT(VsetvlInstruction);
  };

}

#endif //Green_InstructionGPGPU_H
